﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ExcelToSql.Forms
{
    public partial class WorksheetSelector : Form
    {
        string _fileName;
        string[] _sheetNames;

        public WorksheetSelector(string fileName, string[] sheetNames)
        {
            _fileName = fileName;
            _sheetNames = sheetNames;

            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (lstSheets.SelectedItems.Count == 1)
                this.Hide();
        }

        private void WorksheetSelector_Load(object sender, EventArgs e)
        {
            lblMessage.Text = "Select sheet from from file.";

            foreach (string item in _sheetNames)
                lstSheets.Items.Add(item);
        }

        public string SelectedWorksheet
        {
            get
            {
                return lstSheets.SelectedItem.ToString();
            }
        }
    }
}
